package com.yunfeisoft.business.dao.impl.postgres;

import com.applet.base.ServiceDaoImpl;
import com.applet.sql.builder.WhereBuilder;
import com.applet.utils.Page;
import com.yunfeisoft.business.dao.inter.SmsCouponProductCategoryRelationDao;
import com.yunfeisoft.business.model.SmsCouponProductCategoryRelation;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

/**
 * ClassName: SmsCouponProductCategoryRelationDaoImpl
 * Description: 优惠券和产品分类关系表Dao实现
 * Author: Jackie liu
 * Date: 2020-06-02
 */
@Repository
public class SmsCouponProductCategoryRelationDaoImpl extends ServiceDaoImpl<SmsCouponProductCategoryRelation, String> implements SmsCouponProductCategoryRelationDao {

    @Override
    public Page<SmsCouponProductCategoryRelation> queryPage(Map<String, Object> params) {
        WhereBuilder wb = new WhereBuilder();
        if (params != null) {
            initPageParam(wb, params);
        }
        return queryPage(wb);
    }

    /**
     * 根据优惠券id删除优惠券分类关联信息
     * @param couponId
     */
    @Override
    public void deleteByCouponId(String couponId) {
        WhereBuilder wb = new WhereBuilder();
        wb.andEquals("couponId", couponId);
        deleteByCondition(wb);
    }

    /**
     * 根据优惠券id查询优惠券分类列表
     * @param couponId
     * @return
     */
    @Override
    public List<SmsCouponProductCategoryRelation> queryByCouponId(String couponId) {
        WhereBuilder wb = new WhereBuilder();
        wb.andEquals("couponId", couponId);
        return query(wb);
    }
}